<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
    <div>主应用首页</div>
    <button
     @click="login"
    >
      点击登录
    </button>
  </div>
</template>

<script>
import actions from "@/shared/action";
export default {
  name: 'Home',
  data() {
    return {
    }
  },
  mounted() {
    actions.onGlobalStateChange((state, prevState) => {
      console.log('主应用观察者，old Value', prevState);
      console.log('主应用观察者，new Value', state);
    });
  },
  methods: {
    login() {
      setTimeout(() => {
        actions.setGlobalState({ token: Math.random() });
      }, 1000) 
    }
  }
}
</script>
<style lang="less" scoped>
.home{
  padding: 20px;
}
</style>
